
#include <stddef.h>             // for NULL
#include <iostream>
#include "Skill.h"
#include "TextParser.h"
#include "Game.h"
#include "UI.h"

using std::cout; using std::endl;

void CSkill::ShowName()
{
#ifdef _WIN32
	SetConsoleTextAttribute( hConsoleHandle, SKILL_NAME_COLOR|0 );
	cout << szName;
#else
    printf(SKILL_NAME_STRING, szName);
#endif
}

void CSkill::ShowDetail()
{
	ShowName();
	cout << endl;
#ifdef _WIN32
	SetConsoleTextAttribute( hConsoleHandle, DESCRIPTION_COLOR|0);	
	cout << szDesc << endl;
#else
    printf(DESCRIPTION_STRING, szDesc);
    cout << endl;
#endif
	cout << "每升一级增加威力" << nPower <<"。"<<endl;	
}

short CSkill::Damage(short lvl)
{
	return nPower * lvl;
}

short CSkill::MpCost(short lvl)
{
    return nMpCost * lvl;
}

bool CSkill::Load(CTextParser &file)
{
    file.FindRecordHead();
    file.GotoNextLine();
    file.ReadString( szName );
    file.GotoNextLine();
    file.ReadString( szDesc );
		
    file.GotoNextLine();
    file.ReadInteger( &nPower);
    file.GotoNextLine();
    file.ReadInteger( &nLvlUp);
    file.GotoNextLine();
    file.ReadInteger( &nMpCost);
    file.GotoNextLine();
    file.ReadInteger( &nSklCls);
    file.GotoNextLine();
    file.ReadInteger( &nPreExp);
    file.GotoNextLine();
    file.ReadInteger( &nAddExp );

    file.GotoNextLine();
    file.ReadInteger( &nAddHp );
    file.GotoNextLine();
    file.ReadInteger( &nAddMp );
    file.GotoNextLine();
    file.ReadInteger( &nAddAttack );
    file.GotoNextLine();
    file.ReadInteger( &nAddDef );
    file.GotoNextLine();
    file.ReadInteger( &nAddSpeed );
    return true;
}

